Auto merge of #5187 - Eh2406:faster_resolver, r=alexcrichton
authorbors <bors@rust-lang.org>
Sat, 17 Mar 2018 17:49:24 +0000 (17:49 +0000)
committerbors <bors@rust-lang.org>
Sat, 17 Mar 2018 17:49:24 +0000 (17:49 +0000)
commitbdc6fc297c34d196bb216ef2143f7147ed322212
tree33ddd299307ecfdd43626a88f415752d6de03f22
parent545a4a2c930916cc9c3dc1716fb7a33299e4062b
parentc771a4c6b0e24523552fc0db3e8c584957c5ada4
Auto merge of #5187 - Eh2406:faster_resolver, r=alexcrichton

Faster resolver: clean code and the `backtrack_stack`

This is a small extension to #5168 and is inspired by https://github.com/rust-lang/cargo/pull/4834#issuecomment-363518370

After #5168 these work (and don't on cargo from nightly.):
- `safe_core = "=0.22.4"`
- `safe_vault = "=0.13.2"`

But these don't work (and do on cargo from this PR.)
- `crust = "=0.24.0"`
- `elastic = "=0.3.0"`
- `elastic = "=0.4.0"`
- `elastic = "=0.5.0"`
- `safe_vault = "=0.14.0"`

It took some work to figure out why they are not working, and make a test case.

This PR remove use of `conflicting_activations` before it is extended with the conflicting from next.
https://github.com/rust-lang/cargo/pull/5187#issuecomment-373830919
However the `find_candidate(` is still needed so it now gets the conflicting from next before being called.

It often happens that the candidate whose child will fail leading to it's failure, will have older siblings that have already set up `backtrack_frame`s. The candidate knows that it's failure can not be saved by its siblings, but sometimes we activate the child anyway for the error messages. Unfortunately the child does not know that is uncles can't save it, so it backtracks to one of them. Leading to a combinatorial loop.

The solution is to clear the `backtrack_stack` if we are activating just for the error messages.

Edit original end of this message, no longer accurate.
#5168 means that when we find a permanent problem we will never **activate** its parent again. In practise there afften is a lot of work and `backtrack_frame`s between the problem and reactivating its parent. This PR removes `backtrack_frame`s where its parent and the problem are present. This means that when we find a permanent problem we will never **backtrack** into it again.

An alternative is to scan all cashed problems while backtracking, but this seemed more efficient.
src/cargo/core/resolver/mod.rs
tests/testsuite/resolve.rs